home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 17 / AMIGAplus Sonderheft 17 (1999)(ICP)(DE)[!].iso / Rexx / GifToPng.pprx < prev    next >
Text File  |  1997-05-06  |  12KB  |  311 lines

  1. /* Personal Paint Amiga Rexx script - Copyright © 1995-1997 Cloanto Italia srl */
  2.  
  3. /* $VER: GifToPng.pprx 1.1 */
  4.  
  5. /** ENG
  6.   This script asks the user to specify a directory, scans the directory
  7.   and its subdirectories and converts all GIF files it finds into PNG.
  8.  
  9.   Non-GIF files are not affected. Icon images are preserved. Icon format
  10.   information is updated (Tool Types: FILETYPE=PNG). GIF Author, Copyright
  11.   and Comment fields are translated to PNG equivalents. File name suffixes
  12.   are changed (i.e. the files are renamed) as follows:
  13.  
  14.     .gif   -> .png
  15.     .GIF   -> .PNG
  16.     .Gif   -> .Png, etc.
  17.  
  18.     others -> unchanged
  19.  
  20.   Personal Paint identifies the file type by its contents (not by the file
  21.   name suffix). If the script runs during Workbench use, the Workbench Update
  22.   menu item must be selected to visually update the contents of any windows
  23.   containing files being renamed by this script.
  24.  
  25.   This script requires Personal Paint version 7.0 (PPaint Rexx version 7)
  26.   or higher, personal_png_io.library (enclosed with PPaint), and
  27.   personal_gif_io.library (or another GIF-compatible library).
  28.  
  29.  
  30.   Possible changes that could be applied to this file:
  31.  
  32.     Convert all images to PNG (not just GIFs). To do this, change the line
  33.     selecting GIFs to IF UPPER(RESULT) ~= 'PNG' THEN DO. However, be careful
  34.     if you have IFF animations, as they can be loaded as ILBM images unless
  35.     they are filtered out (IFF animations begin with an ILBM image).
  36.  
  37.     Activate PNG Adam 7 progressive display in files being written. This
  38.     degrades compression but the resulting images appear more nicely when
  39.     displayed by progressive viewers. Set PROGDSP=1.
  40.  
  41.     Convert any file to uncompressed IFF-ILBM. This may be good for files to
  42.     be stored on an Amiga CD-ROM, where loading speed could be more important
  43.     than compression. Remove the instructions selecting only GIFs and replace
  44.     the PNG FORMAT option with FORMAT ILBM OPTIONS "COMPR=0" "SCRFMT=0".
  45.  
  46.  
  47.   PNG was designed as a replacement and extension to GIF and LZW-based TIFF,
  48.   after Unisys Corporation began demanding royalties on GIF/LZW code. As
  49.   the PNG specification was released in May 1995, it gained general
  50.   recognition as the best lossless standard for storing digital images.
  51.  
  52.   Cloanto, the first software house to publish a paint program supporting the
  53.   PNG file format, is also making available a PNG developer's kit for the
  54.   Amiga (on the Personal Suite CD-ROM). A PNG DataType is available at no
  55.   cost for free electronic distribution.
  56. */
  57.  
  58. /** DEU
  59.   Die GIF-Bilder im angegebenen Verzeichnis (und in dessen
  60.   Unterverzeichnissen) lassen sich mit Hilfe dieses Skripts automatisch in
  61.   PNG-Bilder umwandeln.
  62.  
  63.   Nicht im GIF-Format vorliegende Bilder werden nicht berücksichtigt;
  64.   Icon-Dateien bleiben grundsätzlich unverändert, allerdings werden die
  65.   Formatinformationen der Formatänderung angepaßt (Merkmale: FILETYPE=PNG).
  66.   Außerdem die durch das GIF-Format unterstützten Felder für Autor,
  67.   Copyright und Kommentar ihren PNG-Äquivalenten angepaßt. Evtl. vorhandene
  68.   Dateinamenerweiterungen werden durch Umbenennung wie folgt geändert:
  69.  
  70.     .gif   -> .png
  71.     .GIF   -> .PNG
  72.     .Gif   -> .Png, usw.
  73.  
  74.     andere -> unverändert
  75.  
  76.   Personal Paint identifiziert das Dateiformat anhand des Dateiinhalts,
  77.   und nicht etwa anhand der Dateinamenerweiterung. Wenn dieses Skript
  78.   während der Benutzung der Workbench ausgeführt wird, muß zunächst
  79.   der Menübefehl "alles aktualisieren" im Menü "Workbench" ausgeführt werden,
  80.   um den Inhalt von Fenstern zu aktualisieren, die von diesem Skript
  81.   modifizierte Dateien enthalten.
  82.  
  83.   Dieses Skript erfordert Personal Paint 7.0 (PPaint Rexx Version 7)
  84.   oder höher, die personal_png_io.library (im Lieferumfang von PPaint
  85.   enthalten) und die personal_gif_io.library (oder eine andere
  86.   GIF-kompatible Library).
  87.  
  88.   Denkbare Änderungen an dieser Skriptdatei:
  89.  
  90.     Konvertierung sämtlicher Bilder (nicht nur GIF) in das PNG-Format.
  91.     Dazu ist die Zeile zur Auswahl der GIF-Bilder in
  92.     IF UPPER(RESULT) ~='PNG' THEN DO zu ändern. Hierbei ist im Hinblick
  93.     auf das Vorhandensein von Animationen im IFF-Format Vorsicht
  94.     walten zu lassen, da auch diese sich als ILBM-Bilder laden lassen
  95.     (IFF-Animationen beginnen mit einem ILBM-Bild).
  96.  
  97.     Aktivierung der "PNG Adam 7 progressive Display"-Option beim Speichern
  98.     der Dateien. Dies führt zwar zu einer verringerten Komprimierungsrate,
  99.     bewirkt aber bei der Anzeige mit einem geeigneten Programme eine
  100.     eine optimierte Darstellung. Set PROGDSP=1.
  101.  
  102.     Konvertierung einer beliebigen Grafikdatei in das umkomprimierte
  103.     IFF-ILBM-Format. Dies kann besonders für Dateien sinnvoll sein, die auf
  104.     einer speziell für den Amiga entwickelten CD-ROM gespeichert werden
  105.     sollen, und wenn die Ladegeschwindigkeit eine höhere Priorität genießt
  106.     als die Komprimierungsrate. Entfernen Sie einfach die Befehle, die
  107.     die Auswahl lediglich auf GIF-Bilder beschränken, und ersetzen Sie die
  108.     Option PNG FORMAT durch FORMAT ILBM OPTIONS "COMPR=0" "SCRFMT=0".
  109.  
  110.   Das PNG-Format wurde als Ersatz und Erweiterung zu GIF und dem
  111.   LZW-basierten TIFF-Format entwickelt, nachdem deren Eigentümer, die
  112.   Firma Unisys, für die Verwendung des GIF-/LZW-Codes Gebühren forderte.
  113.   Kurz nach der Veröffentlichung der PNG-Spezifikation im Mai 1995
  114.   genoß das Format bereits allgemeine Anerkennung als bester verlustfreier
  115.   Standard zur digitalen Bildspeicherung.
  116.  
  117.   Cloanto, die Entwickler des ersten Malprogramms mit PNG-Unterstützung,
  118.   sind auch die Herausgeber des PNG-Entwicklerpakets für den Amiga
  119.   (erhältlich auf der Personal Suite CD-ROM). Zusätzlich ist gratis ein
  120.   PNG-DataType erhältlich, der auf elektronischem Wege frei verteilt werden
  121.   darf.
  122. */
  123.  
  124. /** ITA
  125.   Questo script chiede all'utente di indicare un cassetto, che viene
  126.   poi esaminato insieme agli altri cassetti in esso contenuti per convertire
  127.   tutti i file GIF trovati in file PNG.
  128.  
  129.   File non-GIF non sono modificati. Le immagini delle icone sono conservate.
  130.   Le informazioni dell'icona relative al formato sono aggiornate (Parametri:
  131.   FILETYPE=PNG). I campi Autore, Copyright e Commenti di GIF sono tradotti
  132.   negli equivalenti di PNG. Sono modificati i suffissi del nome file (i file
  133.   sono rinominati) come segue:
  134.  
  135.     .gif   -> .png
  136.     .GIF   -> .PNG
  137.     .Gif   -> .Png, ecc.
  138.  
  139.     altri -> invariati
  140.  
  141.   Personal Paint identifica il tipo del file dal suo contenuto (non dal
  142.   suffisso del nome file). Se si avvia lo script durante l'uso del Workbench,
  143.   si deve selezionare la voce di menu Workbench/Aggiornare tutto per poter
  144.   aggiornare la visualizzazione del contenuto di ogni finestra contenente file
  145.   rinominati da questo script.
  146.  
  147.   Questo script richiede Personal Paint versione 7.0 (PPaint Rexx versione 7)
  148.   o successivo, personal_png_io.library (acclusa a PPaint), e
  149.   personal_gif_io.library (o altra libreria GIF-compatibile).
  150.  
  151.   Possibili modifiche apportabili a questo file:
  152.  
  153.     Convertire tutte le immagini in PNG (not solo quelle GIF). Per fare ciò,
  154.     basta cambiare le linea per la selezione delle immagini GIF in
  155.     IF UPPER(RESULT) ~= 'PNG' THEN DO. Bisogna però fare attenzione se si
  156.     hanno animazioni IFF, poiché possono essere caricate come immagini ILBM
  157.     a meno che non si usi un filtro di esclusione (le animazioni IFF iniziano
  158.     con una immagine ILBM).
  159.  
  160.     Attivare la visualizzazione progressiva PNG Adam 7 nei file che sono
  161.     via via salvati. Ciò peggiora i risultati della compressione ma le
  162.     immagini così ottenute appaiono molto più elegantemente quando sono
  163.     mostrate da visualizzatori progressivi. Impostare PROGDSP=1.
  164.  
  165.     Convertire ogni file in IFF-ILBM non compresso. Ciò può essere utile per
  166.     file da immagazzinare su un CD-ROM per Amiga, dove la velocità di
  167.     caricamento potrebbe essere più importante della compressione. Rimuovere
  168.     le sitruzioni che selezionano solo immagini GIF e sostituire l'opzione
  169.     PNG FORMAT con FORMAT ILBM OPTIONS "COMPR=0" "SCRFMT=0".
  170.  
  171.   PNG è stato progettato come sostituto ed estensione per GIF e TIFF LZW-based,
  172.   dopo che Unisys Corporation iniziò a chiedere royalties sul codice GIF/LZW.
  173.   Da quando le specifiche PNG furono rilasciate nel Maggio 1995, il formato
  174.   ottenne riconoscimenti diffusi come il miglior standard di immagazzinamento
  175.   per immagini digitali senza perdita di informazioni.
  176.  
  177.   Cloanto, la prima software house a pubblicare un programma di disegno che
  178.   consente l'uso del formato PNG, rende disponibile un kit PNG per
  179.   sviluppatori (sul CD-ROM Personal Suite). Un DataType PNG è
  180.   disponibile senza alcun costo via Internet.
  181. */
  182.  
  183. IF ARG(1, EXISTS) THEN
  184.     PARSE ARG PPPORT
  185. ELSE
  186.     PPPORT = 'PPAINT'
  187.  
  188. IF ~SHOW('P', PPPORT) THEN DO
  189.     IF EXISTS('PPaint:PPaint') THEN DO
  190.         ADDRESS COMMAND 'Run >NIL: PPaint:PPaint'
  191.         DO 30 WHILE ~SHOW('P',PPPORT)
  192.              ADDRESS COMMAND 'Wait >NIL: 1 SEC'
  193.         END
  194.     END
  195.     ELSE DO
  196.         SAY "Personal Paint could not be loaded."
  197.         EXIT 10
  198.     END
  199. END
  200.  
  201. IF ~SHOW('P', PPPORT) THEN DO
  202.     SAY 'Personal Paint Rexx port could not be opened'
  203.     EXIT 10
  204. END
  205.  
  206. ADDRESS VALUE PPPORT
  207. OPTIONS RESULTS
  208. OPTIONS FAILAT 10000
  209.  
  210. Get 'LANG'
  211. IF RESULT = 1 THEN DO        /* Deutsch */
  212.     txt_req_sel       = 'GifToPng-Zielverzeichnis'
  213.     txt_err_svabort   = 'Speichervorgang wurde abgebrochen'
  214.     txt_err_ldabort   = 'Ladevorgang wurde abgebrochen'
  215.     txt_err_save      = 'Fehler beim Speichern: '
  216.     txt_err_load      = 'Fehler beim Laden: '
  217.     txt_err_oldclient = 'Für dieses Skript_ist eine neuere Version_von Personal Paint erforderlich'
  218. END
  219. ELSE IF RESULT = 2 THEN DO    /* Italiano */
  220.     txt_req_sel       = 'Selezionare cassetto'
  221.     txt_err_svabort   = 'Scrittura annullata'
  222.     txt_err_ldabort   = 'Lettura annullata'
  223.     txt_err_save      = 'Errore nella scrittura: '
  224.     txt_err_load      = 'Errore nella lettura: '
  225.     txt_err_oldclient = 'Questa procedura richiede_una versione più recente_di Personal Paint'
  226. END
  227. ELSE DO                /* English */
  228.     txt_req_sel       = 'GifToPng target directory'
  229.     txt_err_svabort   = 'User abort during save'
  230.     txt_err_ldabort   = 'User abort during load'
  231.     txt_err_save      = 'Error during save: '
  232.     txt_err_load      = 'Error during load: '
  233.     txt_err_oldclient = 'This script requires a newer_version of Personal Paint'
  234. END
  235.  
  236. Version 'REXX'
  237. IF RESULT < 7 THEN DO
  238.     RequestNotify 'PROMPT "'txt_err_oldclient'"'
  239.     EXIT 10
  240. END
  241.  
  242. LockGUI
  243. FreeBrush
  244. IF RC = 0 THEN
  245.     RequestPath '"'txt_req_sel'"'
  246. IF RC = 0 THEN DO
  247.     tmpfname = 'T:pprx_temp.'PRAGMA('ID')
  248.     ADDRESS COMMAND 'List >'tmpfname' 'RESULT' NOHEAD PAT=~(#?.info) LFORMAT="*"%s%s*"" ALL FILES'
  249.     IF OPEN('listfile', tmpfname, 'R') THEN DO
  250.         Get 'ICONS'
  251.         iconmode = RESULT
  252.         errcode = 0
  253.         Set '"ICONS=3"'
  254.         DO FOREVER
  255.             curfname = READLN('listfile')
  256.             IF EOF('listfile') THEN BREAK
  257.             GetFileFormat curfname
  258.             IF RC = 0 THEN DO
  259.                 IF UPPER(RESULT) = 'GIF' THEN DO
  260.                     LoadBrush curfname 'FORCE'
  261.                     IF RC = 0 THEN DO
  262.                         IF UPPER(RIGHT(curfname, 5)) = '.GIF"' THEN DO
  263.                             len = LENGTH(curfname)
  264.                             newfname = OVERLAY(D2C(C2D(SUBSTR(curfname, len-3, 1)) + 9), curfname, len-3)
  265.                             newfname = OVERLAY(D2C(C2D(SUBSTR(curfname, len-2, 1)) + 5), newfname, len-2)
  266.                             newfname = OVERLAY(D2C(C2D(SUBSTR(curfname, len-1, 1)) + 1), newfname, len-1)
  267.                             IF EXISTS(SUBSTR(newfname,2,len-2)) = 0 THEN DO
  268.                                 ADDRESS COMMAND 'Rename >NIL: 'curfname' 'newfname
  269.                                 curiconfname = INSERT('.info', curfname, len-1)
  270.                                 newiconfname = INSERT('.info', newfname, len-1)
  271.                                 curfname = newfname
  272.                                 IF EXISTS(SUBSTR(curiconfname,2,len+3)) THEN DO
  273.                                     IF EXISTS(SUBSTR(newiconfname,2,len+3)) THEN
  274.                                         ADDRESS COMMAND 'Delete >NIL: 'curiconfname
  275.                                     ELSE
  276.                                         ADDRESS COMMAND 'Rename >NIL: 'curiconfname' 'newiconfname
  277.                                 END
  278.                             END
  279.                         END
  280.                         SaveBrush 'FORCE FILE 'curfname' FORMAT PNG OPTIONS "PROGDSP=0" "COMPR=6" "AUTO=1"'
  281.                         IF RC > 0 THEN DO
  282.                             errcode = RC
  283.                             IF RC = 5 THEN
  284.                                 errmess = txt_err_svabort
  285.                             ELSE
  286.                                 errmess = txt_err_save || RC
  287.                         END
  288.                         FreeBrush 'FORCE'
  289.                     END
  290.                     ELSE DO
  291.                         errcode = RC
  292.                         IF RC = 5 THEN
  293.                             errmess = txt_err_ldabort
  294.                         ELSE
  295.                             errmess = txt_err_load || RC
  296.                     END
  297.                 END
  298.             END
  299.             IF errcode > 0 THEN
  300.                 BREAK
  301.         END
  302.         IF errcode > 0 THEN
  303.             RequestNotify 'PROMPT "'errmess'"'
  304.  
  305.         Set '"ICONS='iconmode'"'
  306.         CALL CLOSE('listfile')
  307.     END
  308.     ADDRESS COMMAND 'Delete >NIL: 'tmpfname
  309. END
  310. UnlockGUI
  311.